{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "33f57b64-8dc9-411d-945d-9e781e013cb8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Table: student_info, Column Name: 学号, Type: BIGINT\n",
      "Table: student_info, Column Name: 姓名, Type: TEXT\n",
      "Table: student_info, Column Name: 性别, Type: TEXT\n",
      "Table: student_info, Column Name: 上课院系, Type: TEXT\n",
      "Table: student_info, Column Name: 专业号, Type: BIGINT\n",
      "Table: student_info, Column Name: 专业名称, Type: TEXT\n",
      "Table: student_info, Column Name: 班级, Type: TEXT\n",
      "Table: student_info, Column Name: 学制, Type: BIGINT\n",
      "Table: student_info, Column Name: 当前所在级, Type: BIGINT\n",
      "Table: student_info, Column Name: 出生日期, Type: BIGINT\n",
      "Table: student_info, Column Name: 身份证件号, Type: TEXT\n",
      "Table: student_info, Column Name: 考生号, Type: BIGINT\n",
      "Table: student_info, Column Name: 入学年份, Type: BIGINT\n",
      "Table: student_info, Column Name: 在校状态, Type: TEXT\n",
      "Table: student_info, Column Name: 学籍状态, Type: TEXT\n",
      "Table: student_info, Column Name: 学生当前状态, Type: TEXT\n",
      "Table: student_info, Column Name: 入学日期, Type: BIGINT\n",
      "Table: student_info, Column Name: 培养层次, Type: TEXT\n",
      "Table: student_info, Column Name: 民族, Type: TEXT\n",
      "Table: table_name, Column Name: column1, Type: BIGINT\n",
      "Table: table_name, Column Name: column2, Type: TEXT\n"
     ]
    }
   ],
   "source": [
    "from sqlalchemy import create_engine, Table, MetaData, inspect\n",
    " \n",
    "# 创建数据库连接引擎和MetaData对象\n",
    "engine = create_engine('sqlite:///database.db')\n",
    "# metadata = MetaData(bind=engine)\n",
    "inspector = inspect(engine)\n",
    " \n",
    "# 获取所有表名\n",
    "table_names = inspector.get_table_names()\n",
    "for table_name in table_names:\n",
    "    columns = inspector.get_columns(table_name)\n",
    "    for column in columns:\n",
    "        print(f\"Table: {table_name}, Column Name: {column['name']}, Type: {column['type']}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
